package com.app.biz.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.core.util.IdUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.AjaxResult;
import com.app.common.enums.BusinessType;
import com.app.biz.domain.BizSecurityConsultation;
import com.app.biz.service.IBizSecurityConsultationService;
import com.app.common.utils.poi.ExcelUtil;
import com.app.common.core.page.TableDataInfo;

/**
 * 安全咨询Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/biz/securityConsultation")
public class BizSecurityConsultationController extends BaseController
{
    @Autowired
    private IBizSecurityConsultationService bizSecurityConsultationService;

    /**
     * 查询安全咨询列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BizSecurityConsultation bizSecurityConsultation)
    {
        startPage();
        List<BizSecurityConsultation> list = bizSecurityConsultationService.selectBizSecurityConsultationList(bizSecurityConsultation);
        return getDataTable(list);
    }

    /**
     * 导出安全咨询列表
     */
    @Log(title = "安全咨询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSecurityConsultation bizSecurityConsultation)
    {
        List<BizSecurityConsultation> list = bizSecurityConsultationService.selectBizSecurityConsultationList(bizSecurityConsultation);
        ExcelUtil<BizSecurityConsultation> util = new ExcelUtil<BizSecurityConsultation>(BizSecurityConsultation.class);
        util.exportExcel(response, list, "安全咨询数据");
    }

    /**
     * 获取安全咨询详细信息
     */
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(bizSecurityConsultationService.selectBizSecurityConsultationByBaseId(baseId));
    }

    /**
     * 新增安全咨询
     */
    @Log(title = "安全咨询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSecurityConsultation bizSecurityConsultation)
    {
        bizSecurityConsultation.setBaseId(IdUtil.simpleUUID());
        bizSecurityConsultation.setBaseCreateTime(new Date());
        return toAjax(bizSecurityConsultationService.insertBizSecurityConsultation(bizSecurityConsultation));
    }

    /**
     * 修改安全咨询
     */
    @Log(title = "安全咨询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSecurityConsultation bizSecurityConsultation)
    {
        return toAjax(bizSecurityConsultationService.updateBizSecurityConsultation(bizSecurityConsultation));
    }

    /**
     * 删除安全咨询
     */
    @Log(title = "安全咨询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(bizSecurityConsultationService.deleteBizSecurityConsultationByBaseIds(baseIds));
    }
}
